//
//  EFengLatestContactSelectCell.m
//  WZEfengAndEtong
//
//  Created by wanzhao on 16/1/21.
//  Copyright © 2016年 wanzhao. All rights reserved.
//

#import "EFengLatestContactSelectCell.h"

@implementation EFengLatestContactSelectCell

+ (instancetype)eFengLatestContactSelectCellWithTableview:(UITableView *)tableView
{
    static NSString *EFengLatestContactSelectCellId = @"EFengLatestContactSelectCellId";
    EFengLatestContactSelectCell *cell = [tableView dequeueReusableCellWithIdentifier:EFengLatestContactSelectCellId];
    if (cell == nil) {
        cell = [[EFengLatestContactSelectCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:EFengLatestContactSelectCellId];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupContactSub];
    }
    return self;
}


- (void)setupContactSub
{
    //    WeakProperty UIView *seperatorLine;
    //    WeakProperty UILabel *departNameLabel;
    //    WeakProperty UIImageView *rightArrow;
    //    WeakProperty UILabel *departCountLabel;
    //    WeakProperty UIButton *departIcon;
    //    WeakProperty UIButton *selectIcon;
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:@"ico-circleDefault"] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"ico-circleClick"] forState:UIControlStateSelected];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:btn];
    self.selectIcon = btn;
    
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.layer.cornerRadius = 3.0f;
    imageView.layer.masksToBounds = YES;
    [self.contentView addSubview:imageView];
    self.headerIcon = imageView;
    
    UIView *sepratiorline = [[UIView alloc] init];
    sepratiorline.backgroundColor = RGBCOLOR(212, 212, 212);
    [self.contentView addSubview:sepratiorline];
    self.seperatorLine = sepratiorline;
    
    
    UIView *shortline = [[UIView alloc] init];
    shortline.backgroundColor = RGBCOLOR(212, 212, 212);
    [self.contentView addSubview:shortline];
    self.shortLine = shortline;
    
    
    UILabel *label1 = [[UILabel alloc] init];
    label1.textAlignment = UITextAlignmentLeft;
    label1.textColor = BlackColor;
    [self.contentView addSubview:label1];
    self.userNameLabel = label1;
    
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    self.selectIcon.frame = CGRectMake(0.0f, 0, self.selectIcon.currentImage.size.width + 30.0f, self.height);
    self.headerIcon.frame = CGRectMake(CGRectGetMaxX(self.selectIcon.frame), 10.0f, 40.0f, 40.0f);
    
    self.userNameLabel.frame = CGRectMake(CGRectGetMaxX(self.headerIcon.frame) + 5.0f, 0, self.width - CGRectGetMaxX(self.headerIcon.frame) - 20.0f, self.height);
    self.seperatorLine.frame = CGRectMake(0, self.height - 0.5f, self.width, 0.5f);
    self.shortLine.frame = CGRectMake(10.0f, self.height - 0.5f, self.width - 10.0f, 0.5f);
}
- (void)btnClick
{
    if ([self.eFengLatestContactSelectCellDelegate respondsToSelector:@selector(eFengLatestContactSelectCellDidselectWithIndexPath:tableView:)]) {
        [self.eFengLatestContactSelectCellDelegate eFengLatestContactSelectCellDidselectWithIndexPath:self.cellIndexPath tableView:self.tableView];
    }
}


@end
